package com.sgb.kjwl.view.ui.adapter.pick;


import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.PermissionMenuEntity;

import java.util.ArrayList;
import java.util.List;

public class SecondtwoMoreAdapter extends BaseQuickAdapter<PermissionMenuEntity.ListEntity, BaseViewHolder> {
    private SecondthreeMoreAdapter adapter;//三级列表适配器
    private boolean isbianji=false;
    private onClickAddlistener clickAddlistener;
    public SecondtwoMoreAdapter(int layoutResId, @Nullable List<PermissionMenuEntity.ListEntity> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PermissionMenuEntity.ListEntity item) {
         helper.setText(R.id.title,item.getTitle());
         //一级列表
         RecyclerView recyclerView = helper.getView(R.id.mRecyclerView);
//        List<String> mlist =new ArrayList<>();
//        for (int i =0;i<4;i++){
//            mlist.add("招标发布");
//        }
        adapter =new SecondthreeMoreAdapter(R.layout.item_secondmore_three,item.getList());
        adapter.setisbianji(isbianji);
        GridLayoutManager linearLayout =new GridLayoutManager(mContext,4){
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        };
        recyclerView.setLayoutManager(linearLayout);
        recyclerView.setAdapter(adapter);
        adapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter threeadapter, View view, int position) {
                switch (view.getId()){
                    case R.id.add:
                        clickAddlistener.addlistener(position,helper.getPosition());
                        break;
                }
            }
        });
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                 clickAddlistener.addItemlistener(position,helper.getPosition());
            }
        });
    }
    public void setClickAddlistener(onClickAddlistener clickAddlistener){
          this.clickAddlistener =clickAddlistener;
    }
    public void setisbianji(boolean isbiani){
        this.isbianji =isbiani;
    }
    interface onClickAddlistener{
          void addlistener(int threepos,int twopos);
          void addItemlistener(int threepos,int twopos);
    }
}
